package tt.com.mourninghallmanager.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import tt.com.common.model.Dead;
import tt.com.common.model.DeadHall;
import tt.com.common.util.CommonResult;
import tt.com.common.util.PageUtil;
import tt.com.mourninghallmanager.Vo.mourninghallVo;
import tt.com.mourninghallmanager.service.DeadHallService;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping(value = "dead/hall")
public class DeadHallController {

    @Autowired
    private DeadHallService deadHallService;

    @PostMapping(value = "show/hall")
    public ResponseEntity showDeadHall(@RequestBody mourninghallVo vo, HttpServletRequest request){
        CommonResult result = deadHallService.showDeadHall(vo.getI(),vo.getPageUtil());
        return new ResponseEntity(result, HttpStatus.valueOf(result.getStatus()));
    }

    @PostMapping(value = "go/hall")
    public ResponseEntity goDeadHall(@RequestBody DeadHall deadHall,HttpServletRequest request){
        CommonResult result = deadHallService.goDeadHall(deadHall);
        return new ResponseEntity(result, HttpStatus.valueOf(result.getStatus()));
    }

    @PostMapping(value = "out/hall")
    public ResponseEntity outDeadHall(@RequestBody DeadHall deadHall,HttpServletRequest request){
        CommonResult result = deadHallService.outDeadHall(deadHall);
        return new ResponseEntity(result, HttpStatus.valueOf(result.getStatus()));
    }

    @PostMapping(value = "update/hall")
    public ResponseEntity updateDeadHall(@RequestBody DeadHall deadHall,HttpServletRequest request){
        CommonResult result = deadHallService.updateDeadHall(deadHall);
        return new ResponseEntity(result,HttpStatus.valueOf(result.getStatus()));
    }

    @PostMapping(value = "insert/hall")
    public ResponseEntity insertDeadHall(@RequestBody DeadHall deadHall,HttpServletRequest request){
        CommonResult result = deadHallService.insertDeadHall(deadHall);
        return new ResponseEntity(result,HttpStatus.valueOf(result.getStatus()));
    }

    @PostMapping(value = "free/hall")
    public ResponseEntity changeFreeDeadHall(@RequestBody PageUtil pageUtil,HttpServletRequest request){
        CommonResult result = deadHallService.changeFreeDeadHall(pageUtil);
        return new ResponseEntity(result,HttpStatus.valueOf(result.getStatus()));
    }

    @PostMapping(value = "add/deadHuman")
    public ResponseEntity addHeadHumanMeassage(@RequestBody Dead dead,HttpServletRequest request){
        CommonResult result = deadHallService.addHeadHumanMeassage(dead);
        return new ResponseEntity(result,HttpStatus.valueOf(result.getStatus()));
    }

    @PostMapping(value = "type/soul")
    public ResponseEntity changeHallTypeBySoul(@RequestBody DeadHall deadHall,HttpServletRequest request){
        CommonResult result = deadHallService.changeHallTypeBySoul(deadHall);
        return new ResponseEntity(result,HttpStatus.valueOf(result.getStatus()));
    }

    @PostMapping(value = "type/leave")
    public ResponseEntity changeHallTypeByLeave(@RequestBody DeadHall deadHall,HttpServletRequest request){
        CommonResult result = deadHallService.changeHallTypeByLeave(deadHall);
        return new ResponseEntity(result,HttpStatus.valueOf(result.getStatus()));
    }

    @PostMapping(value = "del/hall")
    public ResponseEntity deleteDeadHall(@RequestBody DeadHall deadHall,HttpServletRequest request){
        CommonResult result = deadHallService.deleteDeadHall(deadHall);
        return new ResponseEntity(result,HttpStatus.valueOf(result.getStatus()));
    }

    @PostMapping(value = "ref/hall")
    public ResponseEntity refreshDeadHall(@RequestBody PageUtil pageUtil,HttpServletRequest request){
        CommonResult result = deadHallService.refreshDeadHall(pageUtil);
        return new ResponseEntity(result,HttpStatus.valueOf(result.getStatus()));
    }

    @PostMapping(value = "sel/hall")
    public ResponseEntity selectDeadHallMessage(@RequestBody mourninghallVo vo,HttpServletRequest request){
        CommonResult result = deadHallService.selectDeadHallMessage(vo.getDeadHall(),vo.getPageUtil());
        return new ResponseEntity(result,HttpStatus.valueOf(result.getStatus()));
    }
}
